<template>
    <div class="toast-box" >
        <p :class="['toast-value', props.type]">
            <pui-icon :name="tipIcon[props.type]" />{{ value }}
        </p> 
    </div>
</template>    
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
    name: 'Toast'
})
</script>
<script lang="ts" setup>
import { reactive } from 'vue'
import { PuiIcon } from '@photlab/phot-ui'
const tipIcon = reactive({
    warning: '',
    success: 'check',
    error: 'close',
    info: ''
}) as any
const props = defineProps({
    value: {
        type: String,
        default: ''
    },
    duration: {
        type: Number,
        default: 3000
    },
    background: {
        type: String,
        default: '#000'
    },
    color: {
        type: String,
        default: '#fff'
    },
    type: {
        type: String,
        default: 'info' // error warning success info
    }
})
</script>

<style lang="scss" scoped>
@import '~@/assets/styles/theme.scss';
@keyframes anim { 
    0% {opacity: 0;}
    100%{opacity: 1;}
}
@keyframes remove { 
    0% {opacity: 1;}
    100%{opacity: 0;}
}
.toast-box  {
    position: fixed;
    left: 50%;
    top: 55%;
    transform: translate(-50%,-55%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    .toast-value {
        max-width: 150px;
        padding: 4px 10px;
        border-radius: 4px;
        display: flex;
        justify-content: flex-start;
        align-items: baseline;
        animation: anim 0.5s;
        color: #fff;
        font-size: 14px;
        &.remove{
            animation: remove 0.5s;
        }
        &.error {
            background: $danger;
        }
        &.warning {
            background: $warning;
        }
        &.success {
            background: $success;
        }
        &.info {
            background: $primary-fill;
        }
        .pui-icon {
            font-size: 16px;
            color: #fff;
            margin-right: 5px;
        }
    }
}
</style>
    